<?php
namespace App\Model;

use Illuminate\Support\Facades\DB;

class RsRelationshipIntimacyLog extends BaseModel
{

    protected $connection = 'api';
    protected $table = "rs_relationship_intimacy_log";
    protected $fields = ['id',
        'rs_code as rsCode',
        'task_id as taskId',
        'intimate_before as intimateBefore',
        'intimate_change as intimateChange',
        'intimate_after as intimateAfter',
        'change_type as changeType',
        'type',
        'created_time as createdTime'];
    protected $tablePrefix = '';

    public function __construct()
    {
        $this->tablePrefix = env('DB_PREFIX');
    }

    public function getLogs ($rsCode, $type) {
        $rows = DB::connection($this->connection)
            ->table($this->table)
            ->select($this->fields)
            ->where('type', $type)
            ->where('rs_code', $rsCode)
            ->where('is_deleted', 0)
            ->get();
        return $this->objToArray($rows);
    }
}
?>